<?php

class ImageFile  { //extends JFObject {

	protected $imageRes = NULL;

	function __construct(ImageData $imgdata) {
		$this->imageRes = $imgdata->get();
	}
	
	function instance(ImageData $imgdata) {
		return new self( $imgdata );
	}
	
	
	function saveAsJPG($path, $quality = 75) {
		$success = imagejpeg($this->imageRes, $path, $quality );
		if( !$success ) throw new Exception('Could not save as JPG');
	}

	function saveAsPNG($path) {
		$success = imagepng($this->imageRes, $paths);
		if( !$success ) throw new Exception('Could not save as PNG');
	}

	function saveAsGIF($path) {
		$success = imagegif($this->imageRes, $path);
		if( !$success ) throw new Exception('Could not save as GIF');
	}	
}